import { Suspense } from "react";
import Permission from "./Permission";
import LoadingPage from "@/components/Loading/index";
import type { ReactNode } from "react";
const LazyLoad = function (
  Component: ReactNode,
  code: string,
  intoPermission: boolean,
  isLazyLoad: boolean
) {
  return (
    <Permission intoPermission={intoPermission} code={code}>
      {isLazyLoad ? (
        <Suspense fallback={<LoadingPage />}>{Component}</Suspense>
      ) : (
        Component
      )}
    </Permission>
  );
};

export default LazyLoad;
